
_wc:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
  printf(1, "%d %d %d %s\n", l, w, c, name);
}

int
main(int argc, char *argv[])
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	57                   	push   %edi
   4:	56                   	push   %esi
  }
  printf(1, "%d %d %d %s\n", l, w, c, name);
}

int
main(int argc, char *argv[])
   5:	be 01 00 00 00       	mov    $0x1,%esi
{
   a:	53                   	push   %ebx
   b:	83 e4 f0             	and    $0xfffffff0,%esp
   e:	83 ec 20             	sub    $0x20,%esp
  11:	8b 7d 08             	mov    0x8(%ebp),%edi
  }
  printf(1, "%d %d %d %s\n", l, w, c, name);
}

int
main(int argc, char *argv[])
  14:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  17:	83 c3 04             	add    $0x4,%ebx
{
  int fd, i;

  if(argc <= 1){
  1a:	83 ff 01             	cmp    $0x1,%edi
  1d:	7e 63                	jle    82 <main+0x82>
  1f:	90                   	nop
    wc(0, "");
    exit();
  }

  for(i = 1; i < argc; i++){
    if((fd = open(argv[i], 0)) < 0){
  20:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  27:	00 
  28:	8b 03                	mov    (%ebx),%eax
  2a:	89 04 24             	mov    %eax,(%esp)
  2d:	e8 12 04 00 00       	call   444 <open>
  32:	85 c0                	test   %eax,%eax
  34:	78 2d                	js     63 <main+0x63>
      printf(1, "cat: cannot open %s\n", argv[i]);
      exit();
    }
    wc(fd, argv[i]);
  36:	8b 13                	mov    (%ebx),%edx
  if(argc <= 1){
    wc(0, "");
    exit();
  }

  for(i = 1; i < argc; i++){
  38:	83 c6 01             	add    $0x1,%esi
  3b:	83 c3 04             	add    $0x4,%ebx
    if((fd = open(argv[i], 0)) < 0){
      printf(1, "cat: cannot open %s\n", argv[i]);
      exit();
    }
    wc(fd, argv[i]);
  3e:	89 04 24             	mov    %eax,(%esp)
  41:	89 44 24 1c          	mov    %eax,0x1c(%esp)
  45:	89 54 24 04          	mov    %edx,0x4(%esp)
  49:	e8 52 00 00 00       	call   a0 <wc>
    close(fd);
  4e:	8b 44 24 1c          	mov    0x1c(%esp),%eax
  52:	89 04 24             	mov    %eax,(%esp)
  55:	e8 d2 03 00 00       	call   42c <close>
  if(argc <= 1){
    wc(0, "");
    exit();
  }

  for(i = 1; i < argc; i++){
  5a:	39 fe                	cmp    %edi,%esi
  5c:	75 c2                	jne    20 <main+0x20>
      exit();
    }
    wc(fd, argv[i]);
    close(fd);
  }
  exit();
  5e:	e8 a1 03 00 00       	call   404 <exit>
    exit();
  }

  for(i = 1; i < argc; i++){
    if((fd = open(argv[i], 0)) < 0){
      printf(1, "cat: cannot open %s\n", argv[i]);
  63:	8b 03                	mov    (%ebx),%eax
  65:	c7 44 24 04 39 08 00 	movl   $0x839,0x4(%esp)
  6c:	00 
  6d:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  74:	89 44 24 08          	mov    %eax,0x8(%esp)
  78:	e8 d3 04 00 00       	call   550 <printf>
      exit();
  7d:	e8 82 03 00 00       	call   404 <exit>
main(int argc, char *argv[])
{
  int fd, i;

  if(argc <= 1){
    wc(0, "");
  82:	c7 44 24 04 2b 08 00 	movl   $0x82b,0x4(%esp)
  89:	00 
  8a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  91:	e8 0a 00 00 00       	call   a0 <wc>
    exit();
  96:	e8 69 03 00 00       	call   404 <exit>
  9b:	90                   	nop
  9c:	90                   	nop
  9d:	90                   	nop
  9e:	90                   	nop
  9f:	90                   	nop

000000a0 <wc>:

char buf[512];

void
wc(int fd, char *name)
{
  a0:	55                   	push   %ebp
  a1:	57                   	push   %edi
  int i, n;
  int l, w, c, inword;

  l = w = c = 0;
  inword = 0;
  a2:	31 ff                	xor    %edi,%edi

char buf[512];

void
wc(int fd, char *name)
{
  a4:	56                   	push   %esi
  int i, n;
  int l, w, c, inword;

  l = w = c = 0;
  a5:	31 f6                	xor    %esi,%esi

char buf[512];

void
wc(int fd, char *name)
{
  a7:	53                   	push   %ebx
  a8:	83 ec 3c             	sub    $0x3c,%esp
  int i, n;
  int l, w, c, inword;

  l = w = c = 0;
  ab:	c7 44 24 2c 00 00 00 	movl   $0x0,0x2c(%esp)
  b2:	00 
  b3:	c7 44 24 28 00 00 00 	movl   $0x0,0x28(%esp)
  ba:	00 
  bb:	90                   	nop
  bc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  inword = 0;
  while((n = read(fd, buf, sizeof(buf))) > 0){
  c0:	8b 44 24 50          	mov    0x50(%esp),%eax
  c4:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  cb:	00 
  cc:	c7 44 24 04 80 0b 00 	movl   $0xb80,0x4(%esp)
  d3:	00 
  d4:	89 04 24             	mov    %eax,(%esp)
  d7:	e8 40 03 00 00       	call   41c <read>
  dc:	83 f8 00             	cmp    $0x0,%eax
  df:	89 c5                	mov    %eax,%ebp
  e1:	7e 5c                	jle    13f <wc+0x9f>
  e3:	31 db                	xor    %ebx,%ebx
  e5:	eb 0a                	jmp    f1 <wc+0x51>
  e7:	90                   	nop
    for(i=0; i<n; i++){
      c++;
      if(buf[i] == '\n')
        l++;
      if(strchr(" \r\t\n\v", buf[i]))
        inword = 0;
  e8:	31 ff                	xor    %edi,%edi
  int l, w, c, inword;

  l = w = c = 0;
  inword = 0;
  while((n = read(fd, buf, sizeof(buf))) > 0){
    for(i=0; i<n; i++){
  ea:	83 c3 01             	add    $0x1,%ebx
  ed:	39 eb                	cmp    %ebp,%ebx
  ef:	74 38                	je     129 <wc+0x89>
      c++;
      if(buf[i] == '\n')
  f1:	0f be 83 80 0b 00 00 	movsbl 0xb80(%ebx),%eax
        l++;
  f8:	31 d2                	xor    %edx,%edx
      if(strchr(" \r\t\n\v", buf[i]))
  fa:	c7 04 24 16 08 00 00 	movl   $0x816,(%esp)
  inword = 0;
  while((n = read(fd, buf, sizeof(buf))) > 0){
    for(i=0; i<n; i++){
      c++;
      if(buf[i] == '\n')
        l++;
 101:	3c 0a                	cmp    $0xa,%al
 103:	0f 94 c2             	sete   %dl
 106:	01 d6                	add    %edx,%esi
      if(strchr(" \r\t\n\v", buf[i]))
 108:	89 44 24 04          	mov    %eax,0x4(%esp)
 10c:	e8 4f 01 00 00       	call   260 <strchr>
 111:	85 c0                	test   %eax,%eax
 113:	75 d3                	jne    e8 <wc+0x48>
        inword = 0;
      else if(!inword){
 115:	85 ff                	test   %edi,%edi
 117:	75 1f                	jne    138 <wc+0x98>
  int l, w, c, inword;

  l = w = c = 0;
  inword = 0;
  while((n = read(fd, buf, sizeof(buf))) > 0){
    for(i=0; i<n; i++){
 119:	83 c3 01             	add    $0x1,%ebx
        l++;
      if(strchr(" \r\t\n\v", buf[i]))
        inword = 0;
      else if(!inword){
        w++;
        inword = 1;
 11c:	66 bf 01 00          	mov    $0x1,%di
      if(buf[i] == '\n')
        l++;
      if(strchr(" \r\t\n\v", buf[i]))
        inword = 0;
      else if(!inword){
        w++;
 120:	83 44 24 28 01       	addl   $0x1,0x28(%esp)
  int l, w, c, inword;

  l = w = c = 0;
  inword = 0;
  while((n = read(fd, buf, sizeof(buf))) > 0){
    for(i=0; i<n; i++){
 125:	39 eb                	cmp    %ebp,%ebx
 127:	75 c8                	jne    f1 <wc+0x51>
#include "user.h"

char buf[512];

void
wc(int fd, char *name)
 129:	8b 44 24 2c          	mov    0x2c(%esp),%eax
 12d:	01 d8                	add    %ebx,%eax
 12f:	89 44 24 2c          	mov    %eax,0x2c(%esp)
 133:	eb 8b                	jmp    c0 <wc+0x20>
 135:	8d 76 00             	lea    0x0(%esi),%esi
      c++;
      if(buf[i] == '\n')
        l++;
      if(strchr(" \r\t\n\v", buf[i]))
        inword = 0;
      else if(!inword){
 138:	bf 01 00 00 00       	mov    $0x1,%edi
 13d:	eb ab                	jmp    ea <wc+0x4a>
        w++;
        inword = 1;
      }
    }
  }
  if(n < 0){
 13f:	75 38                	jne    179 <wc+0xd9>
    printf(1, "wc: read error\n");
    exit();
  }
  printf(1, "%d %d %d %s\n", l, w, c, name);
 141:	8b 44 24 54          	mov    0x54(%esp),%eax
 145:	89 74 24 08          	mov    %esi,0x8(%esp)
 149:	c7 44 24 04 2c 08 00 	movl   $0x82c,0x4(%esp)
 150:	00 
 151:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 158:	89 44 24 14          	mov    %eax,0x14(%esp)
 15c:	8b 44 24 2c          	mov    0x2c(%esp),%eax
 160:	89 44 24 10          	mov    %eax,0x10(%esp)
 164:	8b 44 24 28          	mov    0x28(%esp),%eax
 168:	89 44 24 0c          	mov    %eax,0xc(%esp)
 16c:	e8 df 03 00 00       	call   550 <printf>
}
 171:	83 c4 3c             	add    $0x3c,%esp
 174:	5b                   	pop    %ebx
 175:	5e                   	pop    %esi
 176:	5f                   	pop    %edi
 177:	5d                   	pop    %ebp
 178:	c3                   	ret    
        inword = 1;
      }
    }
  }
  if(n < 0){
    printf(1, "wc: read error\n");
 179:	c7 44 24 04 1c 08 00 	movl   $0x81c,0x4(%esp)
 180:	00 
 181:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 188:	e8 c3 03 00 00       	call   550 <printf>
    exit();
 18d:	e8 72 02 00 00       	call   404 <exit>
 192:	90                   	nop
 193:	90                   	nop
 194:	90                   	nop
 195:	90                   	nop
 196:	90                   	nop
 197:	90                   	nop
 198:	90                   	nop
 199:	90                   	nop
 19a:	90                   	nop
 19b:	90                   	nop
 19c:	90                   	nop
 19d:	90                   	nop
 19e:	90                   	nop
 19f:	90                   	nop

000001a0 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 1a0:	53                   	push   %ebx
 1a1:	8b 44 24 08          	mov    0x8(%esp),%eax
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 1a5:	31 d2                	xor    %edx,%edx
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 1a7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
 1ab:	90                   	nop
 1ac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 1b0:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
 1b4:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 1b7:	83 c2 01             	add    $0x1,%edx
 1ba:	84 c9                	test   %cl,%cl
 1bc:	75 f2                	jne    1b0 <strcpy+0x10>
    ;
  return os;
}
 1be:	5b                   	pop    %ebx
 1bf:	c3                   	ret    

000001c0 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 1c0:	56                   	push   %esi
 1c1:	53                   	push   %ebx
 1c2:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
 1c6:	8b 54 24 10          	mov    0x10(%esp),%edx
  while(*p && *p == *q)
 1ca:	0f b6 01             	movzbl (%ecx),%eax
 1cd:	0f b6 1a             	movzbl (%edx),%ebx
 1d0:	84 c0                	test   %al,%al
 1d2:	74 24                	je     1f8 <strcmp+0x38>
 1d4:	38 d8                	cmp    %bl,%al
 1d6:	74 11                	je     1e9 <strcmp+0x29>
 1d8:	eb 2e                	jmp    208 <strcmp+0x48>
 1da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 1e0:	83 c1 01             	add    $0x1,%ecx
 1e3:	38 d8                	cmp    %bl,%al
 1e5:	75 21                	jne    208 <strcmp+0x48>
    p++, q++;
 1e7:	89 f2                	mov    %esi,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 1e9:	0f b6 41 01          	movzbl 0x1(%ecx),%eax
    p++, q++;
 1ed:	8d 72 01             	lea    0x1(%edx),%esi
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 1f0:	0f b6 5a 01          	movzbl 0x1(%edx),%ebx
 1f4:	84 c0                	test   %al,%al
 1f6:	75 e8                	jne    1e0 <strcmp+0x20>
    p++, q++;
  return (uchar)*p - (uchar)*q;
 1f8:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 1fb:	31 c0                	xor    %eax,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 1fd:	29 d8                	sub    %ebx,%eax
}
 1ff:	5b                   	pop    %ebx
 200:	5e                   	pop    %esi
 201:	c3                   	ret    
 202:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
    p++, q++;
  return (uchar)*p - (uchar)*q;
 208:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 20b:	0f b6 c0             	movzbl %al,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 20e:	29 d8                	sub    %ebx,%eax
}
 210:	5b                   	pop    %ebx
 211:	5e                   	pop    %esi
 212:	c3                   	ret    
 213:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 219:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000220 <strlen>:

uint
strlen(char *s)
{
 220:	8b 4c 24 04          	mov    0x4(%esp),%ecx
  int n;

  for(n = 0; s[n]; n++)
 224:	31 c0                	xor    %eax,%eax
 226:	80 39 00             	cmpb   $0x0,(%ecx)
 229:	74 10                	je     23b <strlen+0x1b>
 22b:	31 d2                	xor    %edx,%edx
 22d:	8d 76 00             	lea    0x0(%esi),%esi
 230:	83 c2 01             	add    $0x1,%edx
 233:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
 237:	89 d0                	mov    %edx,%eax
 239:	75 f5                	jne    230 <strlen+0x10>
    ;
  return n;
}
 23b:	f3 c3                	repz ret 
 23d:	8d 76 00             	lea    0x0(%esi),%esi

00000240 <memset>:

void*
memset(void *dst, int c, uint n)
{
 240:	57                   	push   %edi
 241:	8b 54 24 08          	mov    0x8(%esp),%edx
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
 245:	8b 4c 24 10          	mov    0x10(%esp),%ecx
 249:	8b 44 24 0c          	mov    0xc(%esp),%eax
 24d:	89 d7                	mov    %edx,%edi
 24f:	fc                   	cld    
 250:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
 252:	89 d0                	mov    %edx,%eax
 254:	5f                   	pop    %edi
 255:	c3                   	ret    
 256:	8d 76 00             	lea    0x0(%esi),%esi
 259:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000260 <strchr>:

char*
strchr(const char *s, char c)
{
 260:	8b 44 24 04          	mov    0x4(%esp),%eax
 264:	0f b6 4c 24 08       	movzbl 0x8(%esp),%ecx
  for(; *s; s++)
 269:	0f b6 10             	movzbl (%eax),%edx
 26c:	84 d2                	test   %dl,%dl
 26e:	74 1d                	je     28d <strchr+0x2d>
    if(*s == c)
 270:	38 ca                	cmp    %cl,%dl
 272:	75 0e                	jne    282 <strchr+0x22>
 274:	eb 1c                	jmp    292 <strchr+0x32>
 276:	66 90                	xchg   %ax,%ax
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 278:	83 c0 01             	add    $0x1,%eax
    if(*s == c)
 27b:	38 ca                	cmp    %cl,%dl
 27d:	8d 76 00             	lea    0x0(%esi),%esi
 280:	74 0e                	je     290 <strchr+0x30>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 282:	0f b6 50 01          	movzbl 0x1(%eax),%edx
 286:	84 d2                	test   %dl,%dl
 288:	75 ee                	jne    278 <strchr+0x18>
    if(*s == c)
      return (char*) s;
  return 0;
 28a:	31 c0                	xor    %eax,%eax
 28c:	c3                   	ret    
 28d:	31 c0                	xor    %eax,%eax
 28f:	90                   	nop
}
 290:	f3 c3                	repz ret 
 292:	f3 c3                	repz ret 
 294:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 29a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

000002a0 <gets>:

char*
gets(char *buf, int max)
{
 2a0:	55                   	push   %ebp
 2a1:	57                   	push   %edi
 2a2:	56                   	push   %esi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2a3:	31 f6                	xor    %esi,%esi
  return 0;
}

char*
gets(char *buf, int max)
{
 2a5:	53                   	push   %ebx
 2a6:	83 ec 2c             	sub    $0x2c,%esp
 2a9:	8b 7c 24 40          	mov    0x40(%esp),%edi
 2ad:	8b 6c 24 44          	mov    0x44(%esp),%ebp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2b1:	eb 38                	jmp    2eb <gets+0x4b>
 2b3:	90                   	nop
 2b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    cc = read(0, &c, 1);
 2b8:	8d 44 24 1f          	lea    0x1f(%esp),%eax
 2bc:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 2c3:	00 
 2c4:	89 44 24 04          	mov    %eax,0x4(%esp)
 2c8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 2cf:	e8 48 01 00 00       	call   41c <read>
    if(cc < 1)
 2d4:	85 c0                	test   %eax,%eax
 2d6:	7e 1a                	jle    2f2 <gets+0x52>
      break;
    buf[i++] = c;
 2d8:	0f b6 44 24 1f       	movzbl 0x1f(%esp),%eax
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2dd:	89 de                	mov    %ebx,%esi
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 2df:	3c 0d                	cmp    $0xd,%al

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
 2e1:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
 2e5:	74 0b                	je     2f2 <gets+0x52>
 2e7:	3c 0a                	cmp    $0xa,%al
 2e9:	74 07                	je     2f2 <gets+0x52>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 2eb:	8d 5e 01             	lea    0x1(%esi),%ebx
 2ee:	39 eb                	cmp    %ebp,%ebx
 2f0:	7c c6                	jl     2b8 <gets+0x18>
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
 2f2:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
 2f6:	83 c4 2c             	add    $0x2c,%esp
 2f9:	89 f8                	mov    %edi,%eax
 2fb:	5b                   	pop    %ebx
 2fc:	5e                   	pop    %esi
 2fd:	5f                   	pop    %edi
 2fe:	5d                   	pop    %ebp
 2ff:	c3                   	ret    

00000300 <stat>:

int
stat(char *n, struct statt *st)
{
 300:	83 ec 1c             	sub    $0x1c,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 303:	8b 44 24 20          	mov    0x20(%esp),%eax
  return buf;
}

int
stat(char *n, struct statt *st)
{
 307:	89 5c 24 14          	mov    %ebx,0x14(%esp)
 30b:	89 74 24 18          	mov    %esi,0x18(%esp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
 30f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 314:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 31b:	00 
 31c:	89 04 24             	mov    %eax,(%esp)
 31f:	e8 20 01 00 00       	call   444 <open>
  if(fd < 0)
 324:	85 c0                	test   %eax,%eax
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 326:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
 328:	78 1a                	js     344 <stat+0x44>
    return -1;
  r = fstat(fd, st);
 32a:	8b 44 24 24          	mov    0x24(%esp),%eax
 32e:	89 1c 24             	mov    %ebx,(%esp)
 331:	89 44 24 04          	mov    %eax,0x4(%esp)
 335:	e8 22 01 00 00       	call   45c <fstat>
  close(fd);
 33a:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
 33d:	89 c6                	mov    %eax,%esi
  close(fd);
 33f:	e8 e8 00 00 00       	call   42c <close>
  return r;
}
 344:	89 f0                	mov    %esi,%eax
 346:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 34a:	8b 74 24 18          	mov    0x18(%esp),%esi
 34e:	83 c4 1c             	add    $0x1c,%esp
 351:	c3                   	ret    
 352:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 359:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000360 <atoi>:

int
atoi(const char *s)
{
 360:	53                   	push   %ebx
 361:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  int n;

  n = 0;
 365:	31 c0                	xor    %eax,%eax
  while('0' <= *s && *s <= '9')
 367:	0f b6 11             	movzbl (%ecx),%edx
 36a:	8d 5a d0             	lea    -0x30(%edx),%ebx
 36d:	80 fb 09             	cmp    $0x9,%bl
 370:	77 1e                	ja     390 <atoi+0x30>
 372:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    n = n*10 + *s++ - '0';
 378:	0f be d2             	movsbl %dl,%edx
 37b:	83 c1 01             	add    $0x1,%ecx
 37e:	8d 04 80             	lea    (%eax,%eax,4),%eax
 381:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 385:	0f b6 11             	movzbl (%ecx),%edx
 388:	8d 5a d0             	lea    -0x30(%edx),%ebx
 38b:	80 fb 09             	cmp    $0x9,%bl
 38e:	76 e8                	jbe    378 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
 390:	5b                   	pop    %ebx
 391:	c3                   	ret    
 392:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 399:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000003a0 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 3a0:	56                   	push   %esi
 3a1:	53                   	push   %ebx
 3a2:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 3a6:	8b 44 24 0c          	mov    0xc(%esp),%eax
 3aa:	8b 74 24 10          	mov    0x10(%esp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 3ae:	85 db                	test   %ebx,%ebx
 3b0:	7e 14                	jle    3c6 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
 3b2:	31 d2                	xor    %edx,%edx
 3b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
 3b8:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 3bc:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 3bf:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 3c2:	39 da                	cmp    %ebx,%edx
 3c4:	75 f2                	jne    3b8 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
 3c6:	5b                   	pop    %ebx
 3c7:	5e                   	pop    %esi
 3c8:	c3                   	ret    
 3c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

000003d0 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 3d0:	56                   	push   %esi
 3d1:	53                   	push   %ebx
 3d2:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 3d6:	8b 44 24 0c          	mov    0xc(%esp),%eax
 3da:	8b 74 24 10          	mov    0x10(%esp),%esi
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 3de:	85 db                	test   %ebx,%ebx
 3e0:	7e 14                	jle    3f6 <memcpy+0x26>
 3e2:	31 d2                	xor    %edx,%edx
 3e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    *dst++ = *src++;
 3e8:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 3ec:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 3ef:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 3f2:	39 da                	cmp    %ebx,%edx
 3f4:	75 f2                	jne    3e8 <memcpy+0x18>

void *
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
}
 3f6:	5b                   	pop    %ebx
 3f7:	5e                   	pop    %esi
 3f8:	c3                   	ret    
 3f9:	90                   	nop
 3fa:	90                   	nop
 3fb:	90                   	nop

000003fc <fork>:
 3fc:	b8 01 00 00 00       	mov    $0x1,%eax
 401:	cd 40                	int    $0x40
 403:	c3                   	ret    

00000404 <exit>:
 404:	b8 02 00 00 00       	mov    $0x2,%eax
 409:	cd 40                	int    $0x40
 40b:	c3                   	ret    

0000040c <wait>:
 40c:	b8 03 00 00 00       	mov    $0x3,%eax
 411:	cd 40                	int    $0x40
 413:	c3                   	ret    

00000414 <pipe>:
 414:	b8 04 00 00 00       	mov    $0x4,%eax
 419:	cd 40                	int    $0x40
 41b:	c3                   	ret    

0000041c <read>:
 41c:	b8 06 00 00 00       	mov    $0x6,%eax
 421:	cd 40                	int    $0x40
 423:	c3                   	ret    

00000424 <write>:
 424:	b8 05 00 00 00       	mov    $0x5,%eax
 429:	cd 40                	int    $0x40
 42b:	c3                   	ret    

0000042c <close>:
 42c:	b8 07 00 00 00       	mov    $0x7,%eax
 431:	cd 40                	int    $0x40
 433:	c3                   	ret    

00000434 <kill>:
 434:	b8 08 00 00 00       	mov    $0x8,%eax
 439:	cd 40                	int    $0x40
 43b:	c3                   	ret    

0000043c <exec>:
 43c:	b8 09 00 00 00       	mov    $0x9,%eax
 441:	cd 40                	int    $0x40
 443:	c3                   	ret    

00000444 <open>:
 444:	b8 0a 00 00 00       	mov    $0xa,%eax
 449:	cd 40                	int    $0x40
 44b:	c3                   	ret    

0000044c <mknod>:
 44c:	b8 0b 00 00 00       	mov    $0xb,%eax
 451:	cd 40                	int    $0x40
 453:	c3                   	ret    

00000454 <unlink>:
 454:	b8 0c 00 00 00       	mov    $0xc,%eax
 459:	cd 40                	int    $0x40
 45b:	c3                   	ret    

0000045c <fstat>:
 45c:	b8 0d 00 00 00       	mov    $0xd,%eax
 461:	cd 40                	int    $0x40
 463:	c3                   	ret    

00000464 <link>:
 464:	b8 0e 00 00 00       	mov    $0xe,%eax
 469:	cd 40                	int    $0x40
 46b:	c3                   	ret    

0000046c <mkdir>:
 46c:	b8 0f 00 00 00       	mov    $0xf,%eax
 471:	cd 40                	int    $0x40
 473:	c3                   	ret    

00000474 <chdir>:
 474:	b8 10 00 00 00       	mov    $0x10,%eax
 479:	cd 40                	int    $0x40
 47b:	c3                   	ret    

0000047c <dup>:
 47c:	b8 11 00 00 00       	mov    $0x11,%eax
 481:	cd 40                	int    $0x40
 483:	c3                   	ret    

00000484 <getpid>:
 484:	b8 12 00 00 00       	mov    $0x12,%eax
 489:	cd 40                	int    $0x40
 48b:	c3                   	ret    

0000048c <sbrk>:
 48c:	b8 13 00 00 00       	mov    $0x13,%eax
 491:	cd 40                	int    $0x40
 493:	c3                   	ret    

00000494 <sleep>:
 494:	b8 14 00 00 00       	mov    $0x14,%eax
 499:	cd 40                	int    $0x40
 49b:	c3                   	ret    
 49c:	90                   	nop
 49d:	90                   	nop
 49e:	90                   	nop
 49f:	90                   	nop

000004a0 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 4a0:	83 ec 2c             	sub    $0x2c,%esp
 4a3:	88 54 24 1c          	mov    %dl,0x1c(%esp)
  write(fd, &c, 1);
 4a7:	8d 54 24 1c          	lea    0x1c(%esp),%edx
 4ab:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 4b2:	00 
 4b3:	89 54 24 04          	mov    %edx,0x4(%esp)
 4b7:	89 04 24             	mov    %eax,(%esp)
 4ba:	e8 65 ff ff ff       	call   424 <write>
}
 4bf:	83 c4 2c             	add    $0x2c,%esp
 4c2:	c3                   	ret    
 4c3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 4c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000004d0 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 4d0:	57                   	push   %edi
 4d1:	56                   	push   %esi
 4d2:	53                   	push   %ebx
 4d3:	89 c3                	mov    %eax,%ebx
 4d5:	83 ec 10             	sub    $0x10,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 4d8:	8b 44 24 20          	mov    0x20(%esp),%eax
 4dc:	85 c0                	test   %eax,%eax
 4de:	74 60                	je     540 <printint+0x70>
 4e0:	89 d0                	mov    %edx,%eax
 4e2:	c1 e8 1f             	shr    $0x1f,%eax
 4e5:	84 c0                	test   %al,%al
 4e7:	74 57                	je     540 <printint+0x70>
    neg = 1;
    x = -xx;
 4e9:	89 d0                	mov    %edx,%eax
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
 4eb:	bf 01 00 00 00       	mov    $0x1,%edi
    x = -xx;
 4f0:	f7 d8                	neg    %eax
  } else {
    x = xx;
  }

  i = 0;
 4f2:	31 f6                	xor    %esi,%esi
 4f4:	eb 04                	jmp    4fa <printint+0x2a>
 4f6:	66 90                	xchg   %ax,%ax
  do{
    buf[i++] = digits[x % base];
 4f8:	89 d6                	mov    %edx,%esi
 4fa:	31 d2                	xor    %edx,%edx
 4fc:	f7 f1                	div    %ecx
 4fe:	0f b6 92 55 08 00 00 	movzbl 0x855(%edx),%edx
  }while((x /= base) != 0);
 505:	85 c0                	test   %eax,%eax
    x = xx;
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 507:	88 14 34             	mov    %dl,(%esp,%esi,1)
 50a:	8d 56 01             	lea    0x1(%esi),%edx
  }while((x /= base) != 0);
 50d:	75 e9                	jne    4f8 <printint+0x28>
  if(neg)
 50f:	85 ff                	test   %edi,%edi
 511:	74 07                	je     51a <printint+0x4a>
    buf[i++] = '-';
 513:	c6 04 14 2d          	movb   $0x2d,(%esp,%edx,1)
 517:	8d 56 02             	lea    0x2(%esi),%edx

  while(--i >= 0)
 51a:	8d 72 ff             	lea    -0x1(%edx),%esi
 51d:	8d 76 00             	lea    0x0(%esi),%esi
    putc(fd, buf[i]);
 520:	0f be 14 34          	movsbl (%esp,%esi,1),%edx
 524:	89 d8                	mov    %ebx,%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 526:	83 ee 01             	sub    $0x1,%esi
    putc(fd, buf[i]);
 529:	e8 72 ff ff ff       	call   4a0 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 52e:	83 fe ff             	cmp    $0xffffffff,%esi
 531:	75 ed                	jne    520 <printint+0x50>
    putc(fd, buf[i]);
}
 533:	83 c4 10             	add    $0x10,%esp
 536:	5b                   	pop    %ebx
 537:	5e                   	pop    %esi
 538:	5f                   	pop    %edi
 539:	c3                   	ret    
 53a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 540:	89 d0                	mov    %edx,%eax
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 542:	31 ff                	xor    %edi,%edi
 544:	eb ac                	jmp    4f2 <printint+0x22>
 546:	8d 76 00             	lea    0x0(%esi),%esi
 549:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000550 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 550:	55                   	push   %ebp
 551:	57                   	push   %edi
 552:	56                   	push   %esi
 553:	53                   	push   %ebx
 554:	83 ec 2c             	sub    $0x2c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 557:	8b 5c 24 44          	mov    0x44(%esp),%ebx
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 55b:	8b 6c 24 40          	mov    0x40(%esp),%ebp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 55f:	0f b6 0b             	movzbl (%ebx),%ecx
 562:	84 c9                	test   %cl,%cl
 564:	0f 84 86 00 00 00    	je     5f0 <printf+0xa0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
 56a:	8d 44 24 48          	lea    0x48(%esp),%eax
{
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 56e:	31 f6                	xor    %esi,%esi
  ap = (uint*)(void*)&fmt + 1;
 570:	89 44 24 1c          	mov    %eax,0x1c(%esp)
 574:	eb 1b                	jmp    591 <printf+0x41>
 576:	66 90                	xchg   %ax,%ax
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 578:	83 f9 25             	cmp    $0x25,%ecx
 57b:	74 7b                	je     5f8 <printf+0xa8>
        state = '%';
      } else {
        putc(fd, c);
 57d:	0f be d1             	movsbl %cl,%edx
 580:	89 e8                	mov    %ebp,%eax
 582:	e8 19 ff ff ff       	call   4a0 <putc>
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 587:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 58a:	0f b6 0b             	movzbl (%ebx),%ecx
 58d:	84 c9                	test   %cl,%cl
 58f:	74 5f                	je     5f0 <printf+0xa0>
    c = fmt[i] & 0xff;
    if(state == 0){
 591:	85 f6                	test   %esi,%esi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
 593:	0f b6 c9             	movzbl %cl,%ecx
    if(state == 0){
 596:	74 e0                	je     578 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 598:	83 fe 25             	cmp    $0x25,%esi
 59b:	75 ea                	jne    587 <printf+0x37>
      if(c == 'd'){
 59d:	83 f9 64             	cmp    $0x64,%ecx
 5a0:	0f 84 ba 00 00 00    	je     660 <printf+0x110>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 5a6:	83 f9 70             	cmp    $0x70,%ecx
 5a9:	74 55                	je     600 <printf+0xb0>
 5ab:	83 f9 78             	cmp    $0x78,%ecx
 5ae:	66 90                	xchg   %ax,%ax
 5b0:	74 4e                	je     600 <printf+0xb0>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 5b2:	83 f9 73             	cmp    $0x73,%ecx
 5b5:	74 71                	je     628 <printf+0xd8>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 5b7:	83 f9 63             	cmp    $0x63,%ecx
 5ba:	0f 84 c3 00 00 00    	je     683 <printf+0x133>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 5c0:	83 f9 25             	cmp    $0x25,%ecx
        putc(fd, c);
 5c3:	ba 25 00 00 00       	mov    $0x25,%edx
 5c8:	89 e8                	mov    %ebp,%eax
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 5ca:	74 12                	je     5de <printf+0x8e>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 5cc:	89 4c 24 18          	mov    %ecx,0x18(%esp)
 5d0:	e8 cb fe ff ff       	call   4a0 <putc>
        putc(fd, c);
 5d5:	8b 4c 24 18          	mov    0x18(%esp),%ecx
 5d9:	89 e8                	mov    %ebp,%eax
 5db:	0f be d1             	movsbl %cl,%edx
 5de:	e8 bd fe ff ff       	call   4a0 <putc>
      }
      state = 0;
 5e3:	31 f6                	xor    %esi,%esi
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 5e5:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 5e8:	0f b6 0b             	movzbl (%ebx),%ecx
 5eb:	84 c9                	test   %cl,%cl
 5ed:	75 a2                	jne    591 <printf+0x41>
 5ef:	90                   	nop
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 5f0:	83 c4 2c             	add    $0x2c,%esp
 5f3:	5b                   	pop    %ebx
 5f4:	5e                   	pop    %esi
 5f5:	5f                   	pop    %edi
 5f6:	5d                   	pop    %ebp
 5f7:	c3                   	ret    
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
        state = '%';
 5f8:	be 25 00 00 00       	mov    $0x25,%esi
 5fd:	eb 88                	jmp    587 <printf+0x37>
 5ff:	90                   	nop
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 600:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 604:	b9 10 00 00 00       	mov    $0x10,%ecx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 609:	31 f6                	xor    %esi,%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 60b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 612:	8b 10                	mov    (%eax),%edx
 614:	89 e8                	mov    %ebp,%eax
 616:	e8 b5 fe ff ff       	call   4d0 <printint>
        ap++;
 61b:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 620:	e9 62 ff ff ff       	jmp    587 <printf+0x37>
 625:	8d 76 00             	lea    0x0(%esi),%esi
      } else if(c == 's'){
        s = (char*)*ap;
 628:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 62c:	8b 38                	mov    (%eax),%edi
        ap++;
 62e:	83 c0 04             	add    $0x4,%eax
 631:	89 44 24 1c          	mov    %eax,0x1c(%esp)
        if(s == 0)
 635:	85 ff                	test   %edi,%edi
 637:	74 64                	je     69d <printf+0x14d>
          s = "(null)";
        while(*s != 0){
 639:	0f b6 17             	movzbl (%edi),%edx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 63c:	31 f6                	xor    %esi,%esi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 63e:	84 d2                	test   %dl,%dl
 640:	0f 84 41 ff ff ff    	je     587 <printf+0x37>
 646:	66 90                	xchg   %ax,%ax
          putc(fd, *s);
 648:	0f be d2             	movsbl %dl,%edx
          s++;
 64b:	83 c7 01             	add    $0x1,%edi
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
 64e:	89 e8                	mov    %ebp,%eax
 650:	e8 4b fe ff ff       	call   4a0 <putc>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 655:	0f b6 17             	movzbl (%edi),%edx
 658:	84 d2                	test   %dl,%dl
 65a:	75 ec                	jne    648 <printf+0xf8>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 65c:	31 f6                	xor    %esi,%esi
 65e:	eb 85                	jmp    5e5 <printf+0x95>
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 660:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 664:	b1 0a                	mov    $0xa,%cl
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 666:	66 31 f6             	xor    %si,%si
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 669:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 670:	8b 10                	mov    (%eax),%edx
 672:	89 e8                	mov    %ebp,%eax
 674:	e8 57 fe ff ff       	call   4d0 <printint>
        ap++;
 679:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 67e:	e9 04 ff ff ff       	jmp    587 <printf+0x37>
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 683:	8b 44 24 1c          	mov    0x1c(%esp),%eax
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 687:	31 f6                	xor    %esi,%esi
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 689:	0f be 10             	movsbl (%eax),%edx
 68c:	89 e8                	mov    %ebp,%eax
 68e:	e8 0d fe ff ff       	call   4a0 <putc>
        ap++;
 693:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 698:	e9 ea fe ff ff       	jmp    587 <printf+0x37>
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
 69d:	bf 4e 08 00 00       	mov    $0x84e,%edi
 6a2:	eb 95                	jmp    639 <printf+0xe9>
 6a4:	90                   	nop
 6a5:	90                   	nop
 6a6:	90                   	nop
 6a7:	90                   	nop
 6a8:	90                   	nop
 6a9:	90                   	nop
 6aa:	90                   	nop
 6ab:	90                   	nop
 6ac:	90                   	nop
 6ad:	90                   	nop
 6ae:	90                   	nop
 6af:	90                   	nop

000006b0 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 6b0:	57                   	push   %edi
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 6b1:	a1 60 0b 00 00       	mov    0xb60,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
 6b6:	56                   	push   %esi
 6b7:	53                   	push   %ebx
 6b8:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
 6bc:	8d 4b f8             	lea    -0x8(%ebx),%ecx
 6bf:	90                   	nop
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 6c0:	39 c8                	cmp    %ecx,%eax
 6c2:	8b 10                	mov    (%eax),%edx
 6c4:	73 04                	jae    6ca <free+0x1a>
 6c6:	39 d1                	cmp    %edx,%ecx
 6c8:	72 16                	jb     6e0 <free+0x30>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 6ca:	39 d0                	cmp    %edx,%eax
 6cc:	72 08                	jb     6d6 <free+0x26>
 6ce:	39 c8                	cmp    %ecx,%eax
 6d0:	72 0e                	jb     6e0 <free+0x30>
 6d2:	39 d1                	cmp    %edx,%ecx
 6d4:	72 0a                	jb     6e0 <free+0x30>
static Header base;
static Header *freep;

void
free(void *ap)
{
 6d6:	89 d0                	mov    %edx,%eax
 6d8:	eb e6                	jmp    6c0 <free+0x10>
 6da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 6e0:	8b 73 fc             	mov    -0x4(%ebx),%esi
 6e3:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 6e6:	39 d7                	cmp    %edx,%edi
 6e8:	74 18                	je     702 <free+0x52>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 6ea:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
 6ed:	8b 50 04             	mov    0x4(%eax),%edx
 6f0:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 6f3:	39 f1                	cmp    %esi,%ecx
 6f5:	74 22                	je     719 <free+0x69>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 6f7:	89 08                	mov    %ecx,(%eax)
  freep = p;
 6f9:	a3 60 0b 00 00       	mov    %eax,0xb60
}
 6fe:	5b                   	pop    %ebx
 6ff:	5e                   	pop    %esi
 700:	5f                   	pop    %edi
 701:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 702:	03 72 04             	add    0x4(%edx),%esi
 705:	89 73 fc             	mov    %esi,-0x4(%ebx)
    bp->s.ptr = p->s.ptr->s.ptr;
 708:	8b 10                	mov    (%eax),%edx
 70a:	8b 12                	mov    (%edx),%edx
 70c:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
 70f:	8b 50 04             	mov    0x4(%eax),%edx
 712:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 715:	39 f1                	cmp    %esi,%ecx
 717:	75 de                	jne    6f7 <free+0x47>
    p->s.size += bp->s.size;
 719:	03 53 fc             	add    -0x4(%ebx),%edx
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
  freep = p;
 71c:	a3 60 0b 00 00       	mov    %eax,0xb60
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 721:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 724:	8b 53 f8             	mov    -0x8(%ebx),%edx
 727:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
}
 729:	5b                   	pop    %ebx
 72a:	5e                   	pop    %esi
 72b:	5f                   	pop    %edi
 72c:	c3                   	ret    
 72d:	8d 76 00             	lea    0x0(%esi),%esi

00000730 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 730:	57                   	push   %edi
 731:	56                   	push   %esi
 732:	53                   	push   %ebx
 733:	83 ec 10             	sub    $0x10,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
 736:	8b 15 60 0b 00 00    	mov    0xb60,%edx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 73c:	8b 5c 24 20          	mov    0x20(%esp),%ebx
 740:	83 c3 07             	add    $0x7,%ebx
 743:	c1 eb 03             	shr    $0x3,%ebx
 746:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
 749:	85 d2                	test   %edx,%edx
 74b:	0f 84 9d 00 00 00    	je     7ee <malloc+0xbe>
 751:	8b 02                	mov    (%edx),%eax
 753:	8b 48 04             	mov    0x4(%eax),%ecx
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
 756:	39 d9                	cmp    %ebx,%ecx
 758:	73 6e                	jae    7c8 <malloc+0x98>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 75a:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
 761:	eb 0e                	jmp    771 <malloc+0x41>
 763:	90                   	nop
 764:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 768:	8b 02                	mov    (%edx),%eax
    if(p->s.size >= nunits){
 76a:	8b 48 04             	mov    0x4(%eax),%ecx
 76d:	39 cb                	cmp    %ecx,%ebx
 76f:	76 57                	jbe    7c8 <malloc+0x98>
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
 771:	3b 05 60 0b 00 00    	cmp    0xb60,%eax
 777:	89 c2                	mov    %eax,%edx
 779:	75 ed                	jne    768 <malloc+0x38>
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 77b:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 781:	b8 00 80 00 00       	mov    $0x8000,%eax
    nu = PAGE;
 786:	be 00 10 00 00       	mov    $0x1000,%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 78b:	76 04                	jbe    791 <malloc+0x61>
 78d:	89 f8                	mov    %edi,%eax
 78f:	89 de                	mov    %ebx,%esi
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
 791:	89 04 24             	mov    %eax,(%esp)
 794:	e8 f3 fc ff ff       	call   48c <sbrk>
  if(p == (char*) -1)
 799:	83 f8 ff             	cmp    $0xffffffff,%eax
 79c:	74 1a                	je     7b8 <malloc+0x88>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
 79e:	89 70 04             	mov    %esi,0x4(%eax)
  free((void*)(hp + 1));
 7a1:	83 c0 08             	add    $0x8,%eax
 7a4:	89 04 24             	mov    %eax,(%esp)
 7a7:	e8 04 ff ff ff       	call   6b0 <free>
  return freep;
 7ac:	8b 15 60 0b 00 00    	mov    0xb60,%edx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
 7b2:	85 d2                	test   %edx,%edx
 7b4:	75 b2                	jne    768 <malloc+0x38>
 7b6:	66 90                	xchg   %ax,%ax
        return 0;
  }
}
 7b8:	83 c4 10             	add    $0x10,%esp
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
 7bb:	31 c0                	xor    %eax,%eax
  }
}
 7bd:	5b                   	pop    %ebx
 7be:	5e                   	pop    %esi
 7bf:	5f                   	pop    %edi
 7c0:	c3                   	ret    
 7c1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
 7c8:	39 cb                	cmp    %ecx,%ebx
 7ca:	74 1c                	je     7e8 <malloc+0xb8>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
 7cc:	29 d9                	sub    %ebx,%ecx
 7ce:	89 48 04             	mov    %ecx,0x4(%eax)
        p += p->s.size;
 7d1:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
        p->s.size = nunits;
 7d4:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
 7d7:	89 15 60 0b 00 00    	mov    %edx,0xb60
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 7dd:	83 c4 10             	add    $0x10,%esp
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 7e0:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 7e3:	5b                   	pop    %ebx
 7e4:	5e                   	pop    %esi
 7e5:	5f                   	pop    %edi
 7e6:	c3                   	ret    
 7e7:	90                   	nop
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
 7e8:	8b 08                	mov    (%eax),%ecx
 7ea:	89 0a                	mov    %ecx,(%edx)
 7ec:	eb e9                	jmp    7d7 <malloc+0xa7>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 7ee:	c7 05 60 0b 00 00 64 	movl   $0xb64,0xb60
 7f5:	0b 00 00 
    base.s.size = 0;
 7f8:	b8 64 0b 00 00       	mov    $0xb64,%eax
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 7fd:	c7 05 64 0b 00 00 64 	movl   $0xb64,0xb64
 804:	0b 00 00 
    base.s.size = 0;
 807:	c7 05 68 0b 00 00 00 	movl   $0x0,0xb68
 80e:	00 00 00 
 811:	e9 44 ff ff ff       	jmp    75a <malloc+0x2a>
